home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / hyperUserInit.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  7.1 KB  |  272 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. // Alias|wavefront Script File
  19. // MODIFY THIS AT YOUR OWN RISK
  20. //
  21. // Creation Date:  21 Jan. 1997
  22. // Author:         corban gossett
  23. //
  24. //
  25. //  Procedure Name:
  26. //
  27. //      hyperUserInit.mel 
  28. //
  29. //  Description:
  30. //              
  31. //        If this script is in your script path, this will allow for simple
  32. //        hypergraph editing. This will work in the "DG" mode of the hypergraph
  33. //        and will allow the ability to build shader networks and other graph 
  34. //        editing for 1.0.  Have fun.....  corban
  35. //
  36. //  Input Arguments:
  37. //      
  38. //  Return Value:
  39. //      
  40.  
  41. global proc nodePressCallback(string $editor, string $node)
  42. {
  43. //
  44. //  Description:
  45. //        Callback when node is pressed
  46. }
  47.  
  48. global proc nodeReleaseCallback(string $editor, string $node, string $mod)
  49. {
  50. //
  51. //  Description:
  52. //        Callback when node is released
  53. }
  54.  
  55. global proc nodeDropCallback(string $editor, string $srcNode, string $dstNode, string $mod)
  56. {
  57. //
  58. //  Description:
  59. //        Callback when node is dropped on another node
  60.  
  61.         string $graphType = `hyperGraph -q -graphType $editor`;
  62.  
  63.         if ($mod == "shift") {
  64.             connectWindowWith $srcNode $dstNode;    
  65.         } else {
  66.             defaultNavigation -f true -ce -s $srcNode -d $dstNode;
  67.         }
  68. }
  69.  
  70. global proc nodeDblClickCallback(string $editor, string $node)
  71. {
  72. //
  73. //  Description:
  74. //        Callback when node is double clicked
  75.  
  76.     hyperGraph -e -attributeEditor single $editor;
  77. }
  78.  
  79. global proc edgePressCallback(string $editor, string $edge)
  80. {
  81. //
  82. //  Description:
  83. //        Callback when edge is pressed
  84. }
  85.  
  86. global proc edgeReleaseCallback(string $editor, string $edge)
  87. {
  88. //
  89. //  Description:
  90. //        Callback when edge is released
  91. }
  92.  
  93. global proc edgeDropCallback(string $editor, string $edge)
  94. {
  95. //
  96. //  Description:
  97. //        Callback when edge is dropped on another edge
  98. }
  99.  
  100. global proc edgeDblClickCallback(string $editor, string $edge)
  101. {
  102. //
  103. //  Description:
  104. //        Callback when edge is double clicked
  105.  
  106.     global string $fromAttr;
  107.     $fromAttr = `hyperGraph -q -fromAttr $editor`;
  108.     global string $toAttr;
  109.     $toAttr = `hyperGraph -q -toAttr $editor`;
  110.  
  111.     connectWindowWith $fromAttr $toAttr;
  112.     
  113. }
  114.  
  115. global proc edgeDimmedDblClickCallback(string $editor, string $edge)
  116. {
  117. //
  118. //  Description:
  119. //        Callback when a dimmed edge is double clicked
  120.  
  121.     minorNodesWindow;;
  122. }
  123.  
  124.  
  125. global proc nodeConnectCallback(string $editor, string $srcNode, string $dstNode, string $direction, string $mod)
  126. {
  127. //
  128. //  Description:
  129. //        Callback when connect request is made by connecting edge
  130.  
  131.     global string $fromAttr;
  132.     $fromAttr = `hyperGraph -q -fromAttr $editor`;
  133.     global string $toAttr;
  134.     $toAttr = `hyperGraph -q -toAttr $editor`;
  135.  
  136.     global string $outliner;
  137.  
  138.  
  139.     if ($direction == "from")
  140.     {
  141.         if (!`window -exists hyperConnectWin`)
  142.         {
  143.             window -ret -title ($srcNode + " -->") -wh 200 450 hyperConnectWin;
  144.             formLayout myForm;
  145.  
  146.             $outliner = `nodeOutliner`;
  147.  
  148.             formLayout -e
  149.                 -af $outliner top 0
  150.                 -af $outliner left 0
  151.                 -af $outliner right 0
  152.                 -af $outliner bottom 0
  153.                 myForm;
  154.         }
  155.         else
  156.         {
  157.             window -e -title ($srcNode + " -->") hyperConnectWin;
  158.             nodeOutliner -e -rma $outliner;
  159.         }
  160.  
  161.         showWindow hyperConnectWin;
  162.         nodeOutliner -e -sh true -snk true -si true -connectivity $toAttr -a $srcNode -so true -snk true $outliner;
  163.         nodeOutliner -e -sc "outSelected" $outliner;
  164.  
  165.  
  166.     }
  167.     else
  168.     {
  169.         if (!`window -exists hyperConnectWin`)
  170.         {    
  171.             window -ret -title ("--> " + $dstNode) -wh 200 450 hyperConnectWin;
  172.             formLayout myForm;
  173.  
  174.             $outliner = `nodeOutliner`;
  175.  
  176.             formLayout -e
  177.                 -af $outliner top 0
  178.                 -af $outliner left 0
  179.                 -af $outliner right 0
  180.                 -af $outliner bottom 0
  181.                 myForm;
  182.         }
  183.         else
  184.         {
  185.             window -e -title ("--> " + $dstNode)  hyperConnectWin;    
  186.             nodeOutliner -e -rma $outliner;
  187.         }
  188.  
  189.         showWindow hyperConnectWin;
  190.         nodeOutliner -e -sh true -snk true -si true -connectivity $fromAttr -a $dstNode -so true -snk true $outliner;
  191.         nodeOutliner -e -sc "inSelected" $outliner;
  192.     }
  193. }
  194.  
  195. global proc disconnectCallback(string $editor, string $srcAttr, string $dstAttr)
  196. {
  197. //
  198. //  Description:
  199. //        Callback when delete connection request is made
  200.     disconnectAttr $srcAttr $dstAttr;
  201. }
  202.  
  203.  
  204. // global proc used for the above proc. (nodeConnectCallback)
  205. // Called from nodeConnectCallback.
  206. //
  207.  
  208. global proc inSelected ()
  209. {
  210.         global string $outliner;
  211.         global string $fromAttr;
  212.         global string $toAttr;
  213.         string $inAttrSelected[0]; 
  214.         $inAttrSelected = `nodeOutliner -q -cs $outliner`;
  215.         disconnectAttr $fromAttr $toAttr;
  216.         print("// Result: disconnected " + $fromAttr + " from " + $toAttr + "\n");
  217.         int $length = `size $inAttrSelected`;
  218.         if( $length > 0 ) {
  219.                 connectAttr $fromAttr $inAttrSelected[0];
  220.                 print("// Result: connected " + $fromAttr + " to " + $inAttrSelected[0] + "\n");
  221.         }
  222.         window -e -visible false hyperConnectWin;
  223.  
  224. }
  225.  
  226. global proc outSelected ()
  227. {
  228.         global string $outliner;
  229.         global string $fromAttr;
  230.         global string $toAttr;
  231.         string $outAttrSelected[0]; 
  232.         $outAttrSelected = `nodeOutliner -q -cs $outliner`;
  233.         disconnectAttr $fromAttr $toAttr;
  234.         print("// Result: disconnected " + $fromAttr + " from " + $toAttr + "\n");
  235.         int $length = `size $outAttrSelected`;
  236.         if( $length > 0 ) {
  237.                 connectAttr $outAttrSelected[0] $toAttr;
  238.                 print("// Result: connected " + $outAttrSelected[0] + " to " + $toAttr + "\n");
  239.         }
  240.         window -e -visible false hyperConnectWin;
  241.  
  242. }
  243.  
  244. global proc
  245. hyperUserInit ( string $editor )
  246. {
  247.     hyperGraph -e 
  248.         -nodePressCommand        nodePressCallback 
  249.         -nodeReleaseCommand     nodeReleaseCallback
  250.         -nodeDropCommand         nodeDropCallback
  251.         -edgePressCommand         edgePressCallback 
  252.         -edgeReleaseCommand     edgeReleaseCallback
  253.         -edgeDropCommand         edgeDropCallback
  254.         -edgeDblClickCommand     edgeDblClickCallback
  255.         -edgeDimmedDblClickCommand     edgeDimmedDblClickCallback
  256.         -nodeConnectCommand        nodeConnectCallback
  257.         -breakConnectionCommand disconnectCallback
  258.         $editor;
  259.         
  260.     // only put the double-click event on HyperShade and Visor
  261.     //
  262.     string $type = `hyperGraph -query -graphType $editor`;
  263.     if ( $type != "DAG" && $type != "DG" ){
  264.         hyperGraph -e
  265.             -nodeDblClickCommand nodeDblClickCallback
  266.             $editor;
  267.     }        
  268. }
  269.  
  270.  
  271.  
  272.